package com.example.activity_service.dao;

import com.example.activity_service.vo.Admin;
import com.example.activity_service.vo.Dui;
import com.example.activity_service.vo.Red;
import com.example.activity_service.vo.Red_goods;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface Jpdao {

    @Select("select * from admins  limit #{ye} ,3")
    List<Admin> admin(int ye);
@Select("select count(*) from admins")
    int totalRecord();
@Insert("insert into admins (name ,ress,imgs) value (#{name},#{dizi},#{tu})")
    void adadmi(String name, String dizi ,String tu);
@Update("update admins set status = #{zt} where id =#{id}")
    void adxiu(String id, String zt);
@Delete("delete from admins  where id=#{id}")
    int schuo(String id);
@Insert("insert into hongbao (redenvelopes,instructions,preferentialway,parvalue,threshold,totalissued,collectiontime,timedata,scopeofapplication,receivingrules,users,receive,sharingoffers,status)values(#{redenvelopes},#{instructions},#{preferentialway},#{parvalue},#{threshold},#{totalissued},NOW(),date_sub(NOW(),interval -3 day),#{scopeofapplication},#{receivingrules},#{users},#{receive},#{sharingoffers},#{status})")
    void addhongbao(Red red);
    @Select("SELECT a.gral,c.commodity_name,c.commodity_picture,d.attribute,d.price FROM dui a,jifendui b,t_commodity c,t_commodity_allocation d where\n" +
            "a.`name`=b.id and b.tid=c.id and b.tcaid=d.id limit #{fe},6 ")
    List<Red_goods> duica(int fe);
@Select("select count(*) from dui")
    int toca();
@Insert("insert into dui (id ,name,numbers,gral,status) value (#{id},#{name},#{numbers},#{gral},1)")
    void adddui(Dui dui);
@Delete("delete from dui where id=#{id}")
    void scdui(String id);
@Update("update dui set name =#{name} ,numbers=#{numbers} ,gral=#{gral} where id=#{id}")
    void xiudui(Dui dui);
}
